<template>
  <div>
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>主要工程量统计表
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(-1)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe606;</span>返回
          </el-button>
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>
    <div class="component-searchHeader">
      <div class="search-header">
        <div class="left-title">
          <p class="left-text">主要工程量统计表</p>
          <div class="right"></div>
        </div>
      </div>
    </div>
    <div class="table">
      <div class="title"><span>工程名称：</span><span>{{titleOne}}</span></div>
      <div class="title"><span>站点名称：</span><span>{{titleTwo}}</span></div>
      <el-table
        ref="multipleTable"
        :data="info"
        tooltip-effect="dark"
        style="width:100%"
        border
      >
        <el-table-column label="序号" width="80" align="center" prop="col_1"></el-table-column>
        <el-table-column label="工作项目名称" align="center" prop="col_2"></el-table-column>
        <el-table-column label="单位" align="center" width="80" prop="col_3"></el-table-column>
        <el-table-column label="费用" align="center" width="col_1">
          <el-table-column
            prop="col_4"
            label="（人天）"
            align="center"
            width="180">
          </el-table-column>
        </el-table-column>
        <el-table-column label="工作量" align="center" width="180">
          <el-table-column
            prop="col_5"
            label="（数量单位参考前面工作项）"
            align="center"
            width="180">
          </el-table-column>
        </el-table-column>
        <el-table-column label="人员单价" align="center" width="180">
          <el-table-column
            prop="col_6"
            label="（元/人/天）"
            align="center"
            width="180">
          </el-table-column>
        </el-table-column>
        <el-table-column label="单项费用" align="center" width="180" prop="col_7"></el-table-column>
      </el-table>
    </div>
    <div class="table">
      <div class="title" style="padding-top: 40px;text-align: center;">光缆、箱体施工明细表</div>
      <el-table
        ref="multipleTable"
        :data="infoTwo"
        tooltip-effect="dark"
        style="width:100%"
        border
      >
        <el-table-column label="镇区" width="80" align="center" prop="col_1"></el-table-column>
        <el-table-column label="社区/村名" align="center" prop="col_2"></el-table-column>
        <el-table-column label="整改类型" align="center" width="80" prop="col_3"></el-table-column>
        <el-table-column label="光缆路由" align="center" width="180" prop="col_4"></el-table-column>
        <el-table-column label="配线箱位置" align="center" width="180" prop="col_5"></el-table-column>
        <el-table-column label="实际验收工程量" align="center" width="180" prop="col_6"></el-table-column>
        <el-table-column label="光缆布放量（百米）" align="center" width="180" prop="col_7"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        // 上表
        info:[{
          name:'光缆布放测量',
          dan:'百米',
          price:'0.08',
          money:'12'
        }],
        // 表头1
        titleOne:"",
        // 表头2
        titleTwo:"",
        // 下表
        infoTwo:[],
        // 合计  ==  表二的小计
        total:""
      };
    },
    created(){

    },
    mounted(){
      this.dataInit();
    },
    methods: {
      dataInit(){
        let that = this,
          suCb = function (res) {
            console.log(res)
            that.info = res.data.data.upData;
            that.infoTwo = res.data.data.downData;
            that.titleOne = res.data.data.row1;
            that.titleTwo = res.data.data.row2;
            that.total = res.data.data.upSumMoney;
            that.info.push({col_7:'合计：'+that.total});
          },
          erCb = function (res) {
            console.log(res)
          },
          palyParam = {
            url: "/api/web/proProject/getBMKMainWorkAccount",
            methods: 'post',
            data: {
              proId : that.$route.query.proId
              // proId:"e289c1d9-679f-418c-beba-a5b30bdc"
            },
            success: suCb,
            error: erCb,
          }
        that.$https(palyParam)
      },
      //合计
      getSummaries(param) {
          const { columns, data } = param;
          const sums = [];
          columns.forEach((column, index) => {
            if (index === 0) {
              sums[index] = '合计';
              return;
            }
            const values = data.map(item => Number(item[column.property]));
            if (!values.every(value => isNaN(value))) {
              if (index == columns.length - 1) {
                sums[index] = values.reduce((prev, curr) => {
                  const value = Number(curr);
                  if (!isNaN(value)) {
                    return prev + curr;
                  } else {
                    return prev;
                  }
                }, 0);
                sums[index] += ' ';
              }
            }
          });
          return sums;
      }
    },
    watch: {}

  };
</script>
<style scoped>
  .component-mainHeader .top .topright {
    font-size: 24px;
  }

  .component-searchHeader .search-header {
    width: 1100px;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
  }

  .component-searchHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-searchHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    line-height: 45px;
    text-align: left;
    margin: 0 0 0 30px;
  }
  .table>div.title{
    border-left:1px solid #e4e4e4;
    border-right:1px solid #e4e4e4;
    height: 45px;
    line-height: 45px;
    color: #666;
    font-size: 14px;
    text-align: left;
    border-bottom: 1px solid #e4e4e4;
  }
  .table>div.title:last-of-type{
    border:none;
  }
  .table>div.title span:first-of-type{
    display: inline-block;
    width: 79px;
    border-right: 1px solid #EBEEF5;
    text-align: center;
  }
  .table>div.title span:last-of-type{
    padding-left: 20px;
  }
  .table{
    width: 1100px;
    margin: 0px auto;
    border-top:none;
  }
</style>
